﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace WebUI.Helpers
{
    public class link
    {
        public static string GetLink(string relativeUri)
        {
            Uri uri = HttpContext.Current.Request.Url;
            string app = HttpContext.Current.Request.ApplicationPath;
            if (!app.EndsWith("/"))
                app += '/';
            relativeUri=relativeUri.TrimStart('/');
            string link = String.Format("http://{0}:{1}{2}{3}", uri.Host, uri.Port, app, relativeUri);
            return link;
        }
        public static string ToUserManager(string filename)
        {
            return GetLink(String.Format("AdminSite/User/{0}",filename));
        }

        public static string ToAdlerLogin(string filename)
        {
            return GetLink(String.Format("{0}", filename));
        }

        public static string toAdminNewsCategory(string filename)
        {
            return GetLink(String.Format("AdminSite/News/{0}", filename));
        }

        public static string ToAdminDetailsNewsCategory(string filename,string no)
        {
            return GetLink(String.Format("AdminSite/News/{0}?Id={1}", filename,no));
        }

        public static string toAdminNewsCatalog(string filename)
        {
            return GetLink(String.Format("AdminSite/Catalog/{0}", filename));
        }

        public static string ToAdminDetailsNewsCatalog(string filename, string no)
        {
            return GetLink(String.Format("AdminSite/Catalog/{0}?Id={1}", filename, no));
        }

        public static string ToAdminDetailsProduct(string filename, string no)
        {
            return GetLink(String.Format("AdminSite/Product/{0}?Id={1}", filename, no));
        }

        public static string ToAdminProduct(string filename)
        {
            return GetLink(String.Format("AdminSite/Product/{0}", filename));
        }

        public static string ToImages(string img)
        {
            return GetLink(String.Format("Images/{0}", img));
        }

        public static string ToPageUrlLink()
        {
            return ToAdminProductColor("ProductColor.aspx") + "?Page={0}";
        }

        public static string ToAdminProductCategory(string filename)
        {
            return GetLink(String.Format("AdminSite/Product/{0}", filename));
        }

        public static string ToAdminProductCategoryDetails(string filename, string no)
        {
            return GetLink(String.Format("Adminsite/Product/{0}?Id={1}", filename, no));
        }

        public static string ToAdminContactDetails(string filename, string no)
        {
            return GetLink(String.Format("Adminsite/Contact/{0}?Id={1}", filename, no));
        }

        public static string ToAdminNewsCategory(string filename)
        {
            return GetLink(String.Format("AdminSite/News/{0}", filename));
        }
        public static string ToAdminProductColor(string filename, int page = 1)
        {
            if (page == 1)
                return GetLink(String.Format("AdminSite/Product/{0}", filename));
            else
            {
                return GetLink(String.Format("AdminSite/Product/{0}?Page={1}", filename, page));
            }
        }
    }
}